home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / programming / arexx / rexxbgui / selectline.rexx < prev    next >
OS/2 REXX Batch file  |  1999-06-14  |  2KB  |  96 lines

  1. /* REXX */
  2. /* REXX script for rexxbgui.library */
  3.  
  4. if ~show('l','rexxbgui.library') then do
  5.     if ~addlib('rexxbgui.library',0,-30) then do
  6.         exit(20)
  7.     end
  8.     else nop
  9. end
  10. else nop
  11.  
  12. fname=arg(1)
  13. if fname='' | (fname='?') then do
  14.     say 'Usage: RX selectline <filename>'
  15.     exit 20
  16. end; else nop
  17. if exists(fname)=0 then do
  18.     say 'File does not exist:' fname
  19.     exit 20
  20. end; else nop
  21.  
  22. call bguiopen() /* causes error 12 if it did not work */
  23. /* supply a second argument for a '0' return code instead of an ARexx
  24.    error */
  25.  
  26. signal on syntax /* important: bguiclose() MUST be called */
  27. signal on halt
  28. signal on break_c
  29.  
  30. if bguireadentries(fname,'LST')~=1 then bguierror(12)
  31. do i=0 to lst.count-1
  32.     lst.i=translate(lst.i,' ','09'x)
  33. end
  34.  
  35. esc='1B'x
  36. lf='0A'x
  37. cr='0D'x
  38. grspace.narrow=-1
  39. grspace.normal=-2
  40. grspace.wide=-3
  41.  
  42. /* using ARexx feature: ,<newline> is translated to nothing */
  43. /* the || are essential - any added space will cause trouble */
  44. /* redefining the same ID makes previous buttons unaccessible */
  45. /* do not redefine winclose etc. */
  46.  
  47. g=bguivgroup(,
  48.     bguivgroup(,
  49.         bguilistview('sslistv',,'LST','S')||,
  50.         bguistring('str',,,256)||bguilayout(LGO_FixMinHeight,1)||,
  51.     '',0)||,
  52.     bguihgroup(,
  53.         bguivarspace(50)||,
  54.         bguibutton('quit','_Quit')||,
  55.         bguivarspace(50),
  56.     )||bguilayout(LGO_FixMinHeight,1),
  57. ,grspace.normal,grspace.normal)
  58.  
  59. call bguiaddmap(obj.sslistv,obj.str,LISTV_Entry,STRINGA_TextVal)
  60.  
  61. a=bguiwindow(fname,g,50,30)
  62.  
  63. call bguiset(obj.sslistv,,BT_RawKey,80) /* F1 */
  64. call bguiset(obj.str,,BT_RawKey,81) /* F2 */
  65.  
  66. if bguiwinopen(a)=0 then bguierror(12) else nop
  67.  
  68. call bguiactivategadget(obj.str,a)
  69.  
  70. id=0
  71. do while bguiwinwaitevent(a,'ID')~=id.winclose
  72.     select
  73.         when id=id.winactive then nop
  74.         when id=id.wininactive then nop
  75.         when id=id.quit then leave
  76.         when id=id.winclose then nop
  77.         otherwise nop
  78.     end
  79. end
  80. res=bguiget(obj.str,STRINGA_TextVal)
  81. call bguiclose()
  82. parse source bla1 reswanted .
  83. if reswanted then return res; else exit 0
  84.  
  85. syntax:
  86. if rc~=0 then say '+++ ['rc']' errortext(rc) 'at line' sigl; else nop
  87. call bguiclose()
  88. exit 10
  89.  
  90. break_c:
  91. halt:
  92. rc=0
  93. say '+++ Break at line' sigl
  94. call bguiclose()
  95. exit 10
  96.